package win.larryzeal.spring.jms.config.listener;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * Created by 张少昆 on 2017/8/5.
 */
@Component
public class MessageListenerTwo {
    @JmsListener( destination = "queue-test" )
    @SendTo( "queue-auto-reply" ) //需要non-void返回值（优先级不如message自带的destination高）
    public void handleMessage(String msg){
        System.out.println("@JmsListener(destination = \"queue-test\") 接收到消息：" + msg);
    }

    @JmsListener( destination = "queue-test" )
    @SendTo( "queue-auto-reply" ) //需要non-void返回值
    public String handleMessage2(String msg){
        System.out.println("@JmsListener(destination = \"queue-test\")2 接收到消息：" + msg);
        return msg;
    }
    @JmsListener( destination = "topic-test",containerFactory = "jmsListenerContainerFactory")
    @SendTo( "topic-auto-reply" ) //需要non-void返回值
    public String handleMessage3(String msg){
        System.out.println("@JmsListener(destination = \"topic-test\") 接收到消息：" + msg);
        return msg;
    }
}
